import axios from "./axios";
import qs from 'qs'

/**********************************************发票****************************************************************/
//批量生产发票
export function createSumInvoice(inv) {
    return axios.post('/manage/working_order/add_summary_invoice.do', qs.stringify(inv))
        .then(res => Promise.resolve(res.data))
}

//批量发票列表
export function getSumInvoiceList(condition) {
    return axios.post('/manage/working_order/show_summary_invoice_list.do', qs.stringify(condition)).then(res => Promise.resolve(res.data))
}

//批量发票详情
export function getSumInvoiceDetail(id) {
    return axios.get(`/manage/working_order/show_summary_invoice_detail.do?id=${id}`).then(res => Promise.resolve(res.data))
}

//生成发票
export function createInvoice({workOrderId, invoiceDateStr, exchangeRateForParts, exchangeRateForPointCode}) {
    return axios.post('/manage/working_order/add_work_order_invoice.do', qs.stringify({
        workOrderId, invoiceDateStr, exchangeRateForParts, exchangeRateForPointCode
    })).then(res => Promise.resolve(res.data))
}

//发票列表
export function getInvoiceList({year, month, startTime, endTime, quarter, weekNumber, customerName, plateNum}) {
    return axios.post('/manage/working_order/show_invoice_list.do', qs.stringify({
        year, month, startTime, endTime, quarter, weekNumber, customerName, plateNum
    })).then(res => Promise.resolve(res.data))
}

//配件人民币发票列表
export function getInvoiceRecipt(search) {
    return axios.post('/parts_stock_out_invoice/manage/show_parts_invoice_list.do', qs.stringify(search))
        .then(res => Promise.resolve(res.data));
}

//修改配件人民币发票列表
export function modifyInvoiceRecipt(invoice) {
    return axios.post('/parts_stock_out_invoice/manage/update_parts_cny_invoice.do', qs.stringify(invoice))
        .then(res => Promise.resolve(res.data))
}

//删除人民币结算列表
export function deleteInvoice(id) {
    return axios.post('/parts_stock_out_invoice/manage/delete_parts_invoice.do?id=' + id)
        .then(res => Promise.resolve(res.data))
}

//新增印尼盾发票
export function addIdrInvoice(invoice) {
    return axios.post('/parts_stock_out_invoice/manage/add_parts_stock_out_invoice.do', qs.stringify(invoice))
        .then(res => Promise.resolve(res.data))
}

// 印尼盾发票修改
export function modIdrInvoice(receipt) {
    return axios.post('/parts_stock_out_invoice/manage/update_invoice_basic_information.do',qs.stringify(receipt)).then(res => Promise.resolve(res.data))
}


//印尼盾发票列表
export function idrInvoiceList(condition) {
    return axios.post('/parts_stock_out_invoice/manage/show_parts_stock_out_invoice_list.do', qs.stringify(condition))
        .then(res => Promise.resolve(res.data))
}

//印尼盾发票详情
export function idrInvoiceDetail(id) {
    return axios.get('/parts_stock_out_invoice/manage/show_invoice_detail.do?id=' + id)
        .then(res => Promise.resolve(res.data))
}

//印尼盾发票删除单条数据
export function deleteIdrInvoice(id) {
    return axios.post('/parts_stock_out_invoice/manage/delete_parts_invoice_detail_by_id.do', qs.stringify({id}))
        .then(res => Promise.resolve(res.data))
}

// 新增或者修改付款
export function addPay(pay) {
    return axios.post('/parts_stock_out_invoice/manage/save_or_update_payment_information.do', qs.stringify(pay)).then(res => Promise.resolve(res.data))
}

// 查看发票付款详情
export function payDetail(invoiceId) {
    return axios.get('/parts_stock_out_invoice/manage/show_payment_information_by_invoice_id.do?invoiceId=' + invoiceId).then(res => Promise.resolve(res.data))
}

//删除
export function deleteAllInvoice(id) {
    return axios.post('/parts_stock_out_invoice/manage/delete_parts_stock_out_invoice.do?id=' + id).then(res => Promise.resolve(res.data))
}

/*=========================================>.<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

//服务发票修改
export function modServiceInvoice(invoice) {
    return axios.post('/manage/working_order/update_work_order_invoice.do', qs.stringify(invoice))
        .then(res => Promise.resolve(res.data))
}

//服务发票删除
export function deleteServiceInvoice(id) {
    return axios.get(`/manage/working_order/delete_work_order_invoice.do?id=${id}`)
        .then(res => Promise.resolve(res.data))
}

//服务发票详情
export function serviceInvoiceDetail(id) {
    return axios.get(`/manage/working_order/show_invoice_detail.do?id=${id}`).then(res => Promise.resolve(res.data))
}

/*=========================================>.<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
